Component({
  data:{
    znjy:String,
    jxjy:String,
    dbyl:String,
    zffd:String,
    zfzj:String,
    sylr:String,
    ywlr:String,
    cdjy:String,
    radioCheckVal:String,
    radioCheckVal1:String,
    radioCheckVal2:String,
    radioCheckVal3:String,
    radioCheckVal4:String,
    add:getApp().data.add,
    showAdd:false
  },
  methods:{
    checkData:function(e){
      // if(!(/^[0-9]+.?[0-9]*$/.test(e.detail.value))){
      //   wx.showToast({
      //     title: '请输入正实数哦',
      //     icon:'none',
      //     duration: 2000
      //   });
      var t = e.detail.value;
      var countD =0;
      for(var g = 0;g<t.length;g++){
        if(t[g]==='.'){
          countD++;
        }
        if((t[g]>'9'||t[g]<'0')&&t[g]!='.'||countD>1){
          wx.showToast({
                title: '请输入正实数哦',
                icon:'none',
                duration: 1000
              });
        }
    }
    },
    radioCheckedChange:function(e){//控制专项附加扣除里面的按钮的颜色
      console.log(e)
      if(e.currentTarget.id === 'a'){
        this.setData({ 
          radioCheckVal:e.detail.value,
          jxjy:e.detail.value
         });
      }else if(e.currentTarget.id === 'b'){
        this.setData({ 
          radioCheckVal1:e.detail.value,
          zffd:e.detail.value
         });
      }else if(e.currentTarget.id === 'c'){
        this.setData({ 
          radioCheckVal2:e.detail.value,
          zfzj:e.detail.value
         });
      }else if(e.currentTarget.id === 'd'){
        this.setData({ 
          radioCheckVal3:e.detail.value,
          cdjy:e.detail.value
        });
      }else{
        this.setData({ 
          radioCheckVal4:e.detail.value,
          ywlr:e.detail.value
        });
      }
     },
     pushData(){
       var data={};
       data.znjy = parseFloat(this.data.znjy);
       data.jxjy = parseFloat(this.data.jxjy);
       data.dbyl = parseFloat(this.data.dbyl);
       data.zffd = parseFloat(this.data.zffd);
       data.zfzj = parseFloat(this.data.zfzj);
       data.sylr = parseFloat(this.data.sylr);
       data.cdjy = 1/parseFloat(this.data.cdjy);
       data.ywlr = parseFloat(this.data.ywlr);
       return data;
     },
     tapDialog:function(){
      this.setData({
        showAdd:false
      })
    },
    tapAdd:function(){
      this.setData({
        showAdd:true
      })
    }
  }
})